package com.sorhis.controller;

import com.sorhis.dto.SysRoleDTO;
import com.sorhis.dto.SysUserDTO;
import com.sorhis.service.ISysRoleService;
import com.sorhis.service.ISysUserService;
import com.sorhis.vo.ResultVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 账号表 前端控制器
 * </p>
 *
 * @author xihao.ding
 * @since 2025-02-08
 */
@RestController
@RequestMapping("/sysRole/v1")
@RequiredArgsConstructor
public class SysRoleController {

    private final ISysRoleService sysRoleService;

    @GetMapping(value = "/list")
    public ResultVO search(SysRoleDTO sysRoleDTO) {
        return ResultVO.ok(sysRoleService.findPageList(sysRoleDTO));
    }

    @PostMapping(value = "/save")
    public ResultVO saveOrUpateUser(@RequestBody SysRoleDTO sysRoleDTO) {
        return ResultVO.ok(sysRoleService.saveOrUpateDomain(sysRoleDTO));
    }

    @PostMapping(value = "/del/{id}")
    public ResultVO del(@PathVariable String id) {
        return ResultVO.ok(sysRoleService.del(id));
    }

    @GetMapping(value = "/all")
    public ResultVO all() {
        return ResultVO.ok(sysRoleService.list());
    }


    /**
     * 角色菜单配置
     * @param sysRoleDTO
     * @return
     */
    @PostMapping(value = "/menu/save")
    public ResultVO roleMenuSave(@RequestBody SysRoleDTO sysRoleDTO) {
        return ResultVO.ok(sysRoleService.roleMenuSave(sysRoleDTO));
    }


}
